'''
Created on Sep 1, 2013

@author: Blaine Buxton
'''
import unittest
import turtle_tracks

import StringIO


class TurtleTracksTest(unittest.TestCase):

    def test_simple(self):
        input_io = StringIO.StringIO('''
11

RT 90
FD 5
RT 135
FD 5
        '''.strip())
        turtle = turtle_tracks.execute(input_io)
        expected='''
...........
...........
...........
...........
...........
.....XXXXXX
.........X.
........X..
.......X...
......X....
.....X.....
        '''.strip()
        self.assertEquals(expected, str(turtle))
        
    def test_box(self):
        input_io = StringIO.StringIO('''
11

REPEAT 4 [ BK 4 RT 90 ]
        '''.strip())
        turtle = turtle_tracks.execute(input_io)
        expected='''
...........
...........
...........
...........
...........
.XXXXX.....
.X...X.....
.X...X.....
.X...X.....
.XXXXX.....
...........
        '''.strip()
        self.assertEquals(expected, str(turtle))
        
    def test_left(self):
        input_io = StringIO.StringIO('''
11

REPEAT 4 [ FD 4 LT 90 ]
        '''.strip())
        turtle = turtle_tracks.execute(input_io)
        print turtle
        expected='''
...........
.XXXXX.....
.X...X.....
.X...X.....
.X...X.....
.XXXXX.....
...........
...........
...........
...........
...........
        '''.strip()
        self.assertEquals(expected, str(turtle))

if __name__ == "__main__":
    unittest.main()